// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    point:'',
    building:'',
    room:[] //房间号数组
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad({point,building}) {
     console.log(point,building);
     //g搞一个数组存房间号
     const room = []
     // 先生成房间个数随机数
      const length = this.getRandom(1,10)
      // 循环遍历
      for (let i = 0; i < length; i++) {
         // 楼层数 
         const floor = this.getRandom(1,9)
         //每层的房间数
         const rooms = this.getRandom(1,3)
        // 生成的房间号 例如：floor + 0 + rooms
        const Fang = `${floor}0${rooms}`
        room.push(Fang)
        // 房间号去重
        if(!room.includes(Fang)){
          room.push(Fang)
        }
        // 排序
        room.sort((a,b) => {
            return a - b
        })
      } 
      this.setData({point,building,room})
   },
   getRandom(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min
  }
})